local benghuai = fk.CreateSkill {

  name = "joy__benghuai",

  tags = { Skill.Compulsory, },

}



benghuai:addEffect(fk.EventPhaseStart, {
  name = "joy__benghuai",
  anim_type = "negative",
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(benghuai.name) and player.phase == Player.Finish then
      return table.find(player.room.alive_players, function (p)
        return p.hp < player.hp
      end)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = room:askForChoice(player, {"loseMaxHp", "loseHp"}, benghuai.name)
    if choice == "loseMaxHp" then
      room:changeMaxHp(player, -1)
    else
      room:loseHp(player, 1, benghuai.name)
    end
    if not player.dead then
      player:drawCards(1, benghuai.name)
    end
  end,
})

return benghuai